home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / joystck.com / JOYDEMO.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-11-14  |  1.7 KB  |  64 lines

  1. program JoystickDemo;
  2. uses CRT,Joystick;
  3.  
  4. var
  5.  X, OX : byte;
  6.  Y, OY : byte;
  7.  
  8. procedure UnHighLight(X,Y : byte);
  9. begin
  10.  Mem[$B800 : ((Y-1)*160)+((X)*2)-1]:=$0F;   { Unhighlight & highlight }
  11. end;                                        { Changes attrib at (X,Y) }
  12.  
  13. procedure HighLight(X,Y : byte);
  14. begin
  15.  Mem[$B800 : ((Y-1)*160)+((X)*2)-1]:=$4F;
  16. end;
  17.  
  18. begin
  19.  BetterInitJS(2);        { Initialize the joystick }
  20.  TextMode(CO80);         { Set to 80x25 color mode }
  21.  TextBackground(Black);  { Set up colors..... }
  22.  TextColor(White);
  23.  ClrScr;
  24.  Writeln('JonSoft Joystick Unit for Turbo Pascal - press any key to end');
  25.  Window(32,5,50,12);
  26.  Writeln('\              /');   { Make joystick 8-direction pattern }
  27.  Writeln('');
  28.  Writeln('');
  29.  Writeln('       C       ',chr(26));
  30.  Writeln('');
  31.  Writeln('');
  32.  Writeln('/              \');
  33.  Window(1,1,80,25);
  34.  GotoXY(20,14);           { Set up indicators }
  35.  Writeln('Button 1 : released   Button 2 : released');
  36.  GotoXY(33,18);
  37.  Writeln('X : xxx   Y : xxx');
  38.  repeat
  39.   GotoXY(37,18);
  40.   Write(JoyX,'   ');     { Update X and Y on the screen }
  41.   GotoXY(47,18);
  42.   Write(JoyY,'   ');
  43.   GotoXY(31,14);
  44.   If Button1=1 then write('PRESSED ')  { Update button info onscreen }
  45.    else write('released');
  46.   GotoXY(53,14);
  47.   If Button2=1 then write('PRESSED ')
  48.    else write('released');
  49.   OX:=X;
  50.   OY:=Y;
  51.   Case Horiz of         { Check 8-direction info, update on screen }
  52.    -1 : X:=32;
  53.     0 : X:=40;
  54.     1 : X:=48;
  55.   end;
  56.   Case Vert of
  57.    -1 : Y:= 5;
  58.     0 : Y:= 8;
  59.     1 : Y:= 11;
  60.   end;
  61.   Unhighlight(OX,OY);
  62.   Highlight(X,Y);
  63.  until keypressed       { Exit when user pressed any key }
  64. end.